﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Shapes;
using System.Windows.Controls;

namespace SwarmMappingAlpha
{
     public class Node
    {
        int xCoordinate;
        int yCoordinate;
        string concatnate;
        int worldHeight;
        private int worldOffset;

        public bool visited
        {
            get;
            set;
        }
        public int nodeNumber
        {
            get;
            set;
        }

        public Node(int x, int y, int number, int _worldHeight, int worldOffset)
        {
            xCoordinate = x;
            yCoordinate = y;
            nodeNumber = number;
            worldHeight = _worldHeight;
            concatnate = this.makeKey();
            this.worldOffset = worldOffset;
        }

        public Node(int x, int y, int number)
        {
            xCoordinate = x;
            yCoordinate = y;
            nodeNumber = number;
            worldHeight = 100;
            concatnate = this.makeKey();
        }

        public string makeKey()
        {
            string xCord = xCoordinate.ToString();
            string yCord = yCoordinate.ToString();
            string finalKey = "";
           
            if (xCoordinate.ToString().Length < 3)
            {
                for (int i = 3 - xCoordinate.ToString().Length; i > 0; i--)
                {
                    xCord = "0" + xCord;
                }
            }

            if (yCoordinate.ToString().Length < 3)
            {
                for (int i = 3 - yCoordinate.ToString().Length; i > 0; i--)
                {
                    yCord = "0" + yCord;
                }
            }

            finalKey = xCord + yCord;
            concatnate = finalKey;
            return finalKey;
        }

        public String Coord
        { 
            get { 
                return "(" + xCoordinate + "," + yCoordinate + ")";
            } 
        }

        public int X
        { get { return xCoordinate; } }

        public int Y
        { get { return yCoordinate; } }

        public Rectangle nodeAsRectangle
        {
            get
            {
                Rectangle nodeRec;
                nodeRec = new Rectangle();
                nodeRec.Width = 3;
                nodeRec.Height = 3;
                //nodeRec.Stroke = 
                nodeRec.StrokeThickness = 1;
                nodeRec.Fill = System.Windows.Media.Brushes.LightPink;
                Canvas.SetLeft(nodeRec, (X - 2.5) );
                Canvas.SetTop(nodeRec, worldHeight - (Y - 2.5) + worldOffset * 2 );
                return nodeRec;
            }
        }
    }
}
